package main

import "fmt"

func binarySearch(arr *[10]int, left int, right int, target int) (middle int) {
	if(left>right){
		return -1
	}
	middle = (left+right)/2
	
	if (*arr)[middle] > target {
		return binarySearch(arr,left,middle-1,target)
	}else if (*arr)[middle] < target{
		return binarySearch(arr,middle+1,right,target)
	}else {
		return middle
	}
}

func main()  {
	
	var arr = [...]int {0,1,2,3,4,5,6,7,8,9}
	fmt.Println(binarySearch(&arr,0,9,9))
}
